//
//  CustomNavigationController.m
//  ZhiLianZhaoPin
//
//  Created by 可 孙 on 12-12-28.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "CustomNavigationController.h"

@implementation CustomNavigationController
@synthesize barView;
@synthesize rightButton;
@synthesize leftButton;
@synthesize centerLable;
- (void)dealloc {
    self.barView=nil;
    self.rightButton=nil;
    self.leftButton=nil;
    self.centerLable=nil;
    [super dealloc];
}


- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.barView=[[UIView alloc]initWithFrame:CGRectMake(0, 20, 320, 44)];
    //给barView设置背景图片
    UIImageView * bgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    [bgView setImage:[UIImage imageNamed:NAVIGATIONBARIMAGE]];
    [self.barView addSubview:bgView];
    [bgView release];
    //初始化控件
    self.leftButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.leftButton.frame=CGRectMake(5, 5, 58, 34);
    self.leftButton.backgroundColor=[UIColor clearColor];
    self.leftButton.titleLabel.font=[UIFont systemFontOfSize:12];
    [self.barView addSubview:self.leftButton];
    
    self.rightButton=[UIButton buttonWithType:UIButtonTypeCustom];
    self.rightButton.frame=CGRectMake(251, 5, 64, 34);
    self.rightButton.backgroundColor=[UIColor clearColor];
    self.rightButton.titleLabel.font=[UIFont systemFontOfSize:12];
    [self.barView addSubview:self.rightButton];
    
    self.centerLable=[[[UILabel alloc]initWithFrame:CGRectMake(80, 0, 160, 44)]autorelease];
    self.centerLable.backgroundColor=[UIColor clearColor];
    self.centerLable.textColor=[UIColor whiteColor];
    self.centerLable.font=[UIFont systemFontOfSize:16];
    self.centerLable.textAlignment=UITextAlignmentCenter;
    [self.barView addSubview:self.centerLable];
    
    [self.view addSubview:self.barView];

}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
